package tests;


import static org.junit.Assert.*;

import java.util.Scanner;

import org.junit.*;
//import org.junit.Assert.*;




import communicationMessages.Message;
import communicationMessages.RegisterMessage;
import database.DB;

public class RegisterTest {


	
	@Test
	public void testRegularRegister()
	{
		Message msg = new RegisterMessage();
		Scanner sc = new Scanner(System.in);
		String userName,password;
		do
		{
			System.out.println("enter userName");
			userName = sc.nextLine();
			System.out.println("enter password");
			password = sc.nextLine();
			 
		}
		while (userName.equals("") || password.equals(""));
		String content = userName + Message.delimiter + password + Message.delimiter;
		msg.setContent(content);
		assertEquals(msg.getAnswer(),"Register"+Message.delimiter+DB.getUserRoll(userName)+Message.delimiter+"success"+Message.delimiter);
	}
	
	@Test
	public void testExistUser()
	{
		String userName = "admin";
		String password = "admin";
		String content = userName + Message.delimiter + password + Message.delimiter;
		Message msg = new RegisterMessage();
		msg.setContent(content);
		assertEquals(msg.getAnswer(),"Register"+Message.delimiter+"guest"+Message.delimiter+"failed"+Message.delimiter+"user name allready exist"+Message.delimiter);
	}
	
	@Test
	public void testWrongParametersList()
	{
		String content = "bla"+ Message.delimiter ;
		Message msg = new RegisterMessage();
		msg.setContent(content);
		assertEquals(msg.getAnswer(),"wrong format"+Message.delimiter);
	}

}
